var fruits = [//对象数组
    {
        fruitName: '红苹果',
        fruitQuantity: 30,
        fruitPrice: 5.8
    },
    {
        fruitName: '青苹果',
        fruitQuantity: 100,
        fruitPrice: 2.8
    },
    {
        fruitName: '黄苹果',
        fruitQuantity: 80,
        fruitPrice: 4
    },
]
// var fruits2 = 0;
// fruits.forEach(function(item){
//     fruits2 = fruits2 + item.fruitQuantity*item.fruitPrice
// })
// console.log(fruits2);
var total =fruits.reduce(function(total,item){
    return total += item.fruitQuantity*item.fruitPrice
},0)
console.log(total);